
module.exports = (options, app) => {
    return async function gzip(ctx, next) {
        let params = ctx.request.body;

        if(Object.keys(params).length == 0){
            params = ctx.query;
        }

        let apiToken = params.api_token || 'cae173455a1ae11294765702943eb797';

        let user = await ctx.model.User.findOne({
            where: {
                access_token: apiToken
            }
        })

        ctx.user = user;

        delete params.api_token;
        await next();
    };
};